<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<%@page import="com.limetalks.data.Comment"%>
<%@page import="com.limetalks.util.Helper"%>
<%@page import="com.limetalks.data.Stream"%>
<%@page import="com.limetalks.data.User"%>
<%@page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8"%>

<html>
<head>
	<title>stream</title>
	<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
	<link rel="stylesheet" type="text/css" href="css/streams.css">
</head>
<body>
	<center>
		<jsp:include page="header.jsp"> 
			<jsp:param name="user" value="" />
		</jsp:include>
		
	
		<div style="font-family:tahoma,arial,verdana,sans-serif,Lucida Sans; font-size:11px; width:800px;">
	
			<% try { 
			 Integer streamId = Integer.valueOf(request.getParameter("streamId")); 
			 Stream stream = Helper.findStreamById(streamId); 
			 if(stream != null) { %>
			<div class="subheader">
				<!--  b>Streams by <a href="author.html" style="color:white; text-decoration:underline;">Vladimir Stalmakov</a></b--> 
				<font color="white"><b><%= stream.getName() %> by <%= stream.getMaster().getName() %></b></font> 
			</div>
			
			<div style="padding-bottom:20px; width:800px;">
			
				<div style="margin-top:10px; margin-left:10px; text-align:left;">
	
					<div class="addCommentLink"><a href="#addComment">Add Comment</a></div>
					<div style="padding-top:10px;"><b>Comments: </b></div>
					<div id="comments" style="padding-top:10px; border-bottom:1px solid #E6E6E6; overflow:auto;">
					
					<% for(Comment comment: Helper.findCommentsByStream(streamId)) { %>
						
						<div class="commentItem">
							<div style="float:left; padding-left:10px;">
								<b><%= Helper.findUserById(comment.getAuthor()).getName() %>:</b> <%= comment.getText() %>
							</div>				
						</div>
	 				<% } %>
	 				
		 			<div id="addComment" style="padding:10px;">
		 				<div style="color:#333333;">Add Comment</div>
							<form method="post" action="AddCommentServlet">
								<textarea rows="5" width="400" name="text" style="width:400px;"></textarea>
								<input type="hidden" name="stream" value="<%= streamId%>"/>
								<input class="commentSubmit" type="submit" id="submit" tabindex="5" value="Publish">
							</form>
						</div> 				
					</div>	
				</div>
			</div>
			
			<script type="text/javascript">
				var height = getClientHeight() - 70 - 200;
				document.getElementById('comments').style.height = height;			
			</script>
			
			<% } else { %>	
				<div class="subheader">Stream does not exist.</div>
			<% }
			} catch (Exception e) { %>
				<div class="subheader">Stream does not exist (Error).</div>
				<div style="padding-left:30px; padding-top:20px; padding-right:30px;">
					<% e.printStackTrace(); %>
				</div>
			<% } %>

		</div>
		
		<jsp:include page="footer.jsp"/>
	
	</center>

</body>
</html>